<template>
  <div>
    <el-radio-group v-model="tabPosition" style="margin-bottom: 20px;">
      <el-radio-button label="overview">总览</el-radio-button>
      <!--<el-radio-button label="detail">详细</el-radio-button>-->
    </el-radio-group>
    <div v-show="tabPosition==='overview'">
      <el-table :data="overviewData" style="width: 100%;" height="500" :header-cell-style="headerCellStyle">
        <el-table-column prop="id" align="center" label="序号" width="150">
        </el-table-column>
        <el-table-column prop="name" align="center" label="领券标题" width="250">
        </el-table-column>
        <el-table-column prop="couponId" align="center" label="优惠券批次" width="250">
        </el-table-column>
        <el-table-column prop="couponName" align="center" label="优惠券名称" width="250">
        </el-table-column>
        <el-table-column prop="receiveNum" align="center" label="参与人数" width="250">
        </el-table-column>
        <el-table-column prop="receiveNum" align="center" label="领取人数" min-width="200">
        </el-table-column>
      </el-table>
      <div class="toolbar" style="padding:10px;">
        <el-pagination
          @size-change="sizeChangeHandle"
          @current-change="currentChangeHandle"
          :current-page="pageIndex"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          :total="totalPage"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </div>
    </div>
    <div v-show="tabPosition==='detail'">
      <el-form label-width="120px"  size="mini" :model="dataForm">
        <el-row>
          <el-col :span="6">
            <el-form-item label="领券标题：">
              <el-input v-model="dataForm.name" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="优惠券名称：">
              <el-input v-model="dataForm.couponName" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="领取时间：">
              <el-date-picker
                style="width: 100%"
                v-model="dataForm.time"
                value-format="yyyy-MM-dd HH:mm:ss"
                :default-time="['00:00:00', '23:59:59']"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="会员账户：">
              <el-input v-model="dataForm.account" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="优惠券批次：">
              <el-input v-model="dataForm.couponInfoId" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" @click="searchInfo()">查询</el-button>
              <el-button @click="reset()">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="detailData" style="width: 100%" height="500" :header-cell-style="headerCellStyle">
        <el-table-column prop="id" align="center" label="序号" width="150">
        </el-table-column>
        <el-table-column prop="name" align="center" label="领券标题" width="250">
        </el-table-column>
        <el-table-column prop="couponInfoId" align="center" label="优惠券批次" width="250">
        </el-table-column>
        <el-table-column prop="couponName" align="center" label="优惠券名称" width="250">
        </el-table-column>
        <el-table-column prop="userName" align="center" label="会员账户" width="250">
        </el-table-column>
        <el-table-column prop="createTime" align="center" label="抽奖时间" min-width="250">
        </el-table-column>
      </el-table>
      <div class="toolbar" style="padding:10px;">
        <el-pagination
          @size-change="sizeChangeHandleInfo"
          @current-change="currentChangeHandleInfo"
          :current-page="pageIndexInfo"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSizeInfo"
          :total="totalPageInfo"
          layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name: "LiveInfoDataCoupon",
    components: {
    },
    data() {
      return {
        headerCellStyle:{
          'background-color': '#f1f1f1'
        },
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        pageIndexInfo: 1,
        pageSizeInfo: 10,
        totalPageInfo: 0,
        tabPosition:'overview',
        overviewData:[],
        detailData:[],
        dataForm:{
          name:'',
          couponName:'',
          time:'',
          account:'',
          couponInfoId:''

        }
      }
    },
    mounted: function () {

    },
    methods: {
      reset(){
        this.dataForm = {}
      },
      searchInfo(){
        this.getdetailData();
      },
      getPData(row){
        this.liveId=row.id;
        this.getDataList()
        this.getdetailData()

      },
      getDataList() {
        let params={};
        params.pageNum=this.pageIndex;
        params.pageSize=this.pageSize;
        params.liveId=this.liveId;
        this.utils.request.liveRequest({
          url: '/api/v1/liveData/getLiveCouponInfoList',
          method:'get',
          params: params
        }).then(result => {
          let data = result.data;
          if (data && data.code == "0") {
            this.overviewData=data.data.rows;
            this.totalPage = data.data.total
          }
        })
      },
      getdetailData(){
        let params={};
        params.pageNum=this.pageIndexInfo;
        params.pageSize=this.pageSizeInfo;
        params.liveId=this.liveId;
        params.name=this.dataForm.name;
        params.couponName=this.dataForm.couponName;
        params.startTime=this.dataForm.time[0];
        params.endTime=this.dataForm.time[1];
        params.userName=this.dataForm.account;
        params.couponInfoId=this.dataForm.couponInfoId;
        this.utils.request.liveRequest({
          url: '/api/v1/liveData/getLiveCouponRecordList',
          method:'get',
          params: params
        }).then(result => {
          let data = result.data;
          if (data && data.code == "0") {
            this.detailData=data.data.rows;
            this.totalPageInfo = data.data.total
          }
        })
      },
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
      sizeChangeHandleInfo(val) {
        this.pageSizeInfo = val
        this.pageIndexInfo = 1
        this.getdetailData()
      },
      // 当前页
      currentChangeHandleInfo(val) {
        this.pageIndexInfo = val
        this.getdetailData()
      },
    }
  }
</script>
<style scoped lang="scss">

</style>
